package com.home.truc.code.components;

import java.awt.Color;
import java.awt.Component;
import java.awt.SystemColor;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import com.home.Entity.Mon;

public class MyJlistItemMon extends JLabel implements ListCellRenderer {

	private static final long serialVersionUID = 1L;
	private static final Color HIGHLIGHT_COLOR = new Color(0, 0, 128);

	  public MyJlistItemMon() {
	    setOpaque(true);
	    setIconTextGap(12);
	  }

	  public Component getListCellRendererComponent(JList list, Object value,
	      int index, boolean isSelected, boolean cellHasFocus) {
	    Mon entry = (Mon) value;
	    setText(entry.getTen());
	    setIcon(entry.getImageIcon());

	    setToolTipText(entry.getTen()+", giá bán: "+String.valueOf(entry.getGiaBan())+", click để xem chi tiết");
	    //setToolTipText(String.valueOf(entry.getGiaBan()));
	    if (isSelected) {
	      setBackground(HIGHLIGHT_COLOR);
	      setForeground(Color.white);
	    } else {
	      setBackground(Color.white);
	      setForeground(Color.black);
	    }
	    return this;
	  }
	}
